Messenger cmdr;

volatile boolean autoRun = false;

void processCmdrMessage();

void initUSB()
{
  //USB com port
  Serial.begin(115200);
}

void initMessenger()
{
  cmdr = Messenger();

  cmdr.attach(processCmdrMessage);
}

void getCmdrMessage()
{
  while(Serial.available() > 0)
    cmdr.process(Serial.read() );
}

void checkRemoteUSBInput()
{
  if (Serial.available())
  {
    char tempChar = Serial.read();

    switch(tempChar)
    {
    case 'w':
      driveMotorsFull();
      break;

    case 's':
      driveMotorsReverse();
      break;

    case 'a':
      latTurnLeft();
      break;

    case 'd':
      latTurnRight();
      break;
      
    case 'x':
      latMotorsKill();
      break;

    case 'r':
      diveMotorsIdle();
      break;

    case 't':
      diveMotorsFull();
      break;
      
    case 'g':
      setFrontLatMotorPos(FULLFORWARD);
      
      break;
      
    case 'h':
      setRearLatMotorPos(FULLFORWARD);
      
      break;

    case 'l':
      allMotorsKill();
      break;

    case 'p':
      autoRun = !autoRun;

      Serial.print("Autorun: ");
      Serial.println(autoRun, BIN);

    default:
      Serial.println("Unrecognized command");
      break;
    }

    Serial.flush();
  }
}
